package com.gxa.web.ServiceManagement;

import com.alibaba.fastjson.JSONObject;
import com.gxa.common.JsonResult;
import com.gxa.service.ServiceService;
import com.gxa.service.impl.ServiceServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//服务反馈-按信息搜索查询
@WebServlet("/service/searchFeedback")
public class SearchServiceFeedbackServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //layui开启分页 就有两个参数：page 当前页面  limit 每页显示条数
        Integer currentPage = Integer.parseInt(request.getParameter("page"));
        Integer pageSize = Integer.parseInt(request.getParameter("limit"));
        //获取服务名称和类型

        String service_name = request.getParameter("service_name");
        System.out.println(service_name);
        String type_name = request.getParameter("type_name");
        System.out.println(type_name);
        //调用ServiceService
        if (service_name.isEmpty()){
            service_name=null;
        }
        if (type_name.equals("不限")){
            type_name=null;
        }
        ServiceService serviceService = new ServiceServiceImp();
        JsonResult jsonResult = serviceService.queryServieFeedbackList(currentPage,pageSize,service_name,type_name);
        //把jsonResult转成JSON格式数据，响应回给页面
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(jsonResult));

    }
}
